package com.eddie.tree.threadedbinarytree;

/**
 * @author Eddie
 * @date 2022/08/10 10:22
 **/
public class ThreadedBinaryTreeDemo {
    public static void main(String[] args) {
        //测试中序线索二叉树功能是否正确
        HeroNode root = new HeroNode(1, "Tom");
        HeroNode node2 = new HeroNode(3, "jack");
        HeroNode node3 = new HeroNode(6, "smith");
        HeroNode node4 = new HeroNode(8, "mary");
        HeroNode node5 = new HeroNode(10, "king");
        HeroNode node6 = new HeroNode(14, "dim");
        //二叉树后续递归创建，暂时简单处理：手动创建
        root.setLeft(node2);
        root.setRight(node3);
        node2.setLeft(node4);
        node2.setRight(node5);
        node3.setLeft(node6);
        //测试线索化
        ThreadedBinaryTree threadedBinaryTree = new ThreadedBinaryTree();
        threadedBinaryTree.setRoot(root);
        threadedBinaryTree.threadedNodes();

        //以10号节点测试，看一下前驱和后继
        HeroNode left = node5.getLeft();
        System.out.println("10号节点的前驱节点是：" + left);

        HeroNode right = node5.getRight();
        System.out.println("10号节点的后继节点是：" + right);

        System.out.println("使用线索化方式遍历线索化二叉树");
        threadedBinaryTree.threadedList();
    }
}


